package com.sg.plmadapter.windchill.page;

import java.util.Map;

import com.sg.business.model.Document;
import com.sg.business.model.Folder;
import com.sg.plmadapter.adapters.PDMAdapter;
import com.sg.widgets.commons.model.IURLProvider;

public class ObjectInformationPage implements IURLProvider {

	public ObjectInformationPage() {
	}

	@SuppressWarnings("rawtypes")
	@Override
	public String getURL(Object data) {
		if(data instanceof Document){
			Folder folder = ((Document) data).getFolder();
			Folder container = folder.getContainer();
			Object type = container.getValue(Folder.F_CONTAINER_TYPE);
			if(PDMAdapter.CONTAINER_WINDCHILL.equals(type)){
				String host = (String) container.getValue(PDMAdapter.F_WINDCHILL_HOST);
				Map plmData = (Map) ((Document) data).getValue(Document.F_PLM_DATA);
				String plmmid = (String) plmData.get("plmmid");
				return getURL(host,plmmid);
						 
			}
		}
		return null;
	}

	private String getURL(String host, String plmid) {
		return host+plmid;
	}
	
}
